<?php

namespace app\admin\controller;

use think\Controller;

class Index extends Base
{
    public function index(){
        $data['total_order']=db('order')->where('order_status','>=',1)->count();
        $timetoday = strtotime(date("Y-m-d",time()));
        $data['today_order']=db('order')->where('order_status','>=',1)->where('order_ctime','>',$timetoday)->count();
        $data['today_tuple']=db('tuple')->where('tuple_ctime','>=',$timetoday)->count();
        $data['total_users']=db('user')->count();
        $data['today_money']=0;
        $today_tuple=db('tuple')->where('tuple_ctime','>=',$timetoday)->select();
        foreach ($today_tuple as $k=>$v){
            $add=db('order')->where('order_id',$v['tuple_order_id'])->value('order_price');
            $data['today_money']=$data['today_money']+$add;
        }
        $data['total_money']=0;
        $total_tuple=db('tuple')->select();
        foreach ($total_tuple as $k=>$v){
            $add=db('order')->where('order_id',$v['tuple_order_id'])->value('order_price');
            $data['total_money']=$data['total_money']+$add;
        }
        $this->assign('data',$data);
        return $this->fetch();
    }
}
